package com.二维数组查找;
//思路：每一列的第一个数去比较，若大于找的数那么就去下一列否则就去这列查找
public class Solution {
	public static void main(String[] args) {
		Solution s = new Solution();
		int array[][]= {{1,2,8,9},{2,4,9,12},{4,7,10,13},{6,8,11,15}};
		System.out.println(s.Find(7, array));
	}
    public boolean Find(int target, int [][] array) {
        int x = array[0].length-1;
        int y = array.length-1;
        int temp = array[x][y];
        int i=x,j=y;
        while(i>=0&&j>=0){
        	System.out.println(array[i][j]);
            if(array[i][j]<target){
               j--;
            }
            else if(array[i][j]>target){
                i--;
            }
            else{
                return true;
            }
        }
        return false;
    }
}
